﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VirtualPress.Infrastructure.Entities.Repository;
using VirtualPress.Tool.Framework;

namespace VirtualPress.Infrastructure.Entities.Entity
{
    public class FriendLink : IAccessible<T_FriendLink, FriendLink>, ILogicEntity<T_FriendLink, FriendLink>
    {
        #region Fileds
        public int Id { get; set; }
        public int RelationId { get; set; }
        /// <summary>
        /// 1:期刊 2:会议
        /// </summary>
        public int RelationType { get; set; }
        public string Title { get; set; }
        public string URL { get; set; }
        public string Remark { get; set; }
        public DateTime CreateTime { get; set; }
        #endregion


        protected override void Covariant(T_FriendLink model)
        {
            if (model != null)
            {
                this.Id = model.Id;
                this.RelationId = model.RelationId;
                this.RelationType = model.RelationType;
                this.Title = model.Title;
                this.URL = model.URL;
                this.Remark = model.Remark;
                this.CreateTime = model.CreateTime;
            }
        }

        protected override T_FriendLink Inverter(FriendLink model)
        {
            if(model != null)
            {
                return new T_FriendLink()
                {
                    CreateTime = model.CreateTime,
                    Id = model.Id,
                    RelationId=model.RelationId,
                    RelationType=model.RelationType,
                    Remark = model.Remark,
                    Title = model.Title,
                    URL = model.URL
                };
            }
            return null;
        }

        public FriendLink Set(T_FriendLink dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
